
import javax.microedition.io.CommConnection;
import javax.microedition.lcdui.*;
/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */

/**
 *
 * @author student
 */
public class Menu extends Form implements ItemCommandListener, CommandListener {

    private StringItem btn_newgame, btn_setting, btn_highscore, btn_about, btn_quit;
    private Command CMD_new, CMD_set, CMD_high, CMD_about, CMD_quit;
    private final Command CMD_BACK = new Command("Back", Command.BACK, 1);
    private final Command CMD_EXIT = new Command("Exit", Command.EXIT, 2);
    Main Main;
    public Menu() {
        super("");

        this.append(new Spacer(240, 30));

        btn_newgame = new StringItem("", "  New Game  ", StringItem.BUTTON);
        btn_newgame.setLayout(StringItem.LAYOUT_CENTER);
        CMD_new = new Command("Select", Command.ITEM, 0);
        btn_newgame.setDefaultCommand(CMD_new);
        btn_newgame.setItemCommandListener(this);
        this.append(btn_newgame);


        this.append(new Spacer(240, 30));

        btn_setting = new StringItem("", "    Setting    ", StringItem.BUTTON);
        btn_setting.setLayout(StringItem.LAYOUT_CENTER);
        CMD_set = new Command("Select", Command.ITEM, 0);
        btn_setting.setDefaultCommand(CMD_set);
        btn_setting.setItemCommandListener(this);
        this.append(btn_setting);


        this.append(new Spacer(240, 30));

        btn_highscore = new StringItem("", " High Score ", StringItem.BUTTON);
        btn_highscore.setLayout(StringItem.LAYOUT_CENTER);
        CMD_high = new Command("Select", Command.ITEM, 0);
        btn_highscore.setDefaultCommand(CMD_high);
        btn_highscore.setItemCommandListener(this);
        this.append(btn_highscore);


        this.append(new Spacer(240, 30));

        btn_about = new StringItem("", "    About    ", StringItem.BUTTON);
        btn_about.setLayout(StringItem.LAYOUT_CENTER);
        CMD_about = new Command("Select", Command.ITEM, 0);
        btn_about.setDefaultCommand(CMD_about);
        btn_about.setItemCommandListener(this);
        this.append(btn_about);


        this.append(new Spacer(240, 30));

        btn_quit = new StringItem("", "     Quit     ", StringItem.BUTTON);
        btn_quit.setLayout(StringItem.LAYOUT_CENTER);
        CMD_quit = new Command("Select", Command.ITEM, 0);
        btn_quit.setDefaultCommand(CMD_quit);
        btn_quit.setItemCommandListener(this);
        this.append(btn_quit);


        this.addCommand(CMD_BACK);
        this.addCommand(CMD_EXIT);
        this.setCommandListener(this);
    }

    public void commandAction(Command c, Item item) {
        if (c == CMD_new) {
            Manager.setCurrent(Manager.GameBackground);
        }
        if (c == CMD_set) {
        }
        if (c == CMD_high) {
        }
        if (c == CMD_about) {
        }
        if (c == CMD_quit) {
            Main.destroyApp(true);
        }
    }

    public void commandAction(Command c, Displayable d) {
        if (c == CMD_BACK) {
            Manager.setCurrent(Manager.C_Splash);
        }
        if (c == CMD_EXIT) {
            Main.destroyApp(true);
        }
    }
}
